-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/bca/space explore pagination #3926
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few remarks from a static review. Also the CI was not happy, can you have a look please?
* @param limit a client-defined limit to the maximum number of rooms to return per page. Must be a non-negative integer. | ||
* @param maxDepth: Optional: The maximum depth in the tree (from the root room) to return. | ||
* @param from: Optional. Pagination token given to retrieve the next set of rooms. Note that if a pagination token is provided, | ||
* then the parameters given for suggested_only and max_depth must be the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_depth
is not a part of this API, the SDK forces the value to 1.
So either expose max_depth
to the client applications here, or update this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed comment
// } | ||
// } | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it worth commenting all the code about auto-join? Maybe just make sure that the value is always set to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto-join was removed and will probably not be designed like this, I commented out just to remember where it was done to help future implementation
}.orEmpty() | ||
} | ||
.orEmpty() | ||
SpaceHierarchySummary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpaceHierarchySummary
name is a bit confusing to me (at least at first sight). I proposeSpaceHierarchyData
, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
internal interface SpaceApi { | ||
|
||
/** | ||
* @param limit: Optional: a client-defined limit to the maximum number of rooms to return per page. Must be a non-negative integer. | ||
* @param max_depth: Optional: The maximum depth in the tree (from the root room) to return. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxDepth
is the actual parameter name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
* The fields are the same as those returned by /publicRooms (see spec), with the addition of: | ||
* room_type: the value of the m.type field from the room's m.room.create event, if any. | ||
* children_state: The m.space.child events of the room. | ||
* For each event, only the following fields are included1: type, state_key, content, room_id, sender, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in included1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -62,7 +62,7 @@ class SpaceCardRenderer @Inject constructor( | |||
inCard.matrixToAccessImage.isVisible = true | |||
inCard.matrixToAccessImage.setImageResource(R.drawable.ic_room_private) | |||
} | |||
val memberCount = spaceSummary.otherMemberIds.size | |||
val memberCount = spaceSummary.joinedMembersCount?.let { it - 1 } ?: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why decrementing the value here? Maybe add a comment to clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The summay object here is constructed from space summary API, so it does not have all the info as a real summary from DB would have (like the list of user ids of members). So I switched to using joinedMembersCount, but i believe that joinedMemberCount is counting current user unlike otherMemberIds, so decremented to keep same result as before.
I'll check if I can't just use that number indeed
errorWithRetryItem { | ||
id("error_${currentRootId}_${hierarchySummary.nextToken}") | ||
text(host.errorFormatter.toHumanReadable(paginationStatus.error)) | ||
listener { host.listener?.retry() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling retry()
is not correct here, you should call host.listener?.loadAdditionalItemsIfNeeded()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to be on the safe side and retry all since the beginning, but I can just retry pagination
session.getRoomSummary(it.childRoomId) | ||
?.takeIf { it.membership == Membership.JOIN } // only take if joined because it will be up to date (synced) | ||
} | ||
}.distinctBy { it.roomId } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding this call to distinctBy()
? The server can send duplicates? If it is the case, it's probably better to handle that SDK side.
errorWithRetryItem { | ||
id("error_$nextToken") | ||
text(host.errorFormatter.toHumanReadable(paginationStatus.error)) | ||
listener { host.listener?.retry() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
host.listener?.loadAdditionalItemsIfNeeded()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
575f600
to
1c7e567
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
Fixes #3693
This PR add supports for the Space Summary API pagination (deprecation of
org.matrix.msc2946/rooms/{roomId}/spaces
in favor oforg.matrix.msc2946/rooms/{roomId}/hierarchy
)Element Android only uses the hierarchy API with depth 1.
The pagination is triggered seamlesly when the user reaches the last item of the list (using epoxy visibility tracker on a bottom loading item). Pagination results are cached and kept in memory as long as the screen is visible.
This PR is also doing a quick cleaning by removing support for auto-join, that has been postponed for a later release
Here is a sample with some low page size: